<template>
  <div id="addActives">
    <el-row type="flex" justiify="center">
      <el-col :span="12" :offset="0">
        <h1 class="con-right-title">
          新增抽奖活动
        </h1>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="22" :offset="1">
        <el-form
          ref="addActives"
          :model="marketingAddCommandModel.activityInfo"
          label-width="150px"
          :rules="addActivesRules"
          size="small"
        >
          <el-form-item label="活动名称：" prop="name">
            <el-input
              @blur="
                marketingAddCommandModel.activityInfo.name = $event.target.value.trim()
              "
              style="width: 50%"
              type="text"
              show-word-limit
              :clearable="true"
              :maxLength="maxLength"
              v-model="marketingAddCommandModel.activityInfo.name"
            ></el-input>
          </el-form-item>
          <el-form-item label="活动起始时间：" prop="activeTime">
            <el-col :span="11">
              <el-date-picker
                v-model="marketingAddCommandModel.activityInfo.activeTime"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                @change="getTime"
              >
              </el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="预热时间：" prop="hotFireTime">
            <el-radio-group
              v-model="marketingAddCommandModel.activityInfo.warmUpConfig.open"
            >
              <el-radio :label="true">开启</el-radio>
              <el-radio :label="false">关闭</el-radio>
            </el-radio-group>
            <div
              v-if="
                marketingAddCommandModel.activityInfo.warmUpConfig.open == true
              "
            >
              <el-date-picker
                v-model="marketingAddCommandModel.activityInfo.hotFireTime"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy-MM-dd HH-mm"
                value-format="yyyy-MM-dd HH:mm:ss"
                @change="getHotTime"
              >
              </el-date-picker>
              <div style="margin-top: 20px">
                <uploadSingImg
                  :imgUrl="
                    marketingAddCommandModel.activityInfo.warmUpConfig.cover
                  "
                  accept=".jpg,.jpeg,.png,.gif"
                  :maxSize="5"
                  @getImgUrl="getImgUrl"
                >
                  <template v-slot:imgInfo
                    >（请上传图片尺寸1242*2688，支持gif，尺寸最大5M）</template
                  >
                </uploadSingImg>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="领奖时间：" prop="getAwardTime">
            <el-radio-group
              v-model="
                marketingAddCommandModel.activityInfo.receiveAwardConfig.open
              "
            >
              <el-radio :label="true">开启</el-radio>
              <el-radio :label="false">关闭</el-radio>
            </el-radio-group>
            <div
              v-if="
                marketingAddCommandModel.activityInfo.receiveAwardConfig.open ==
                  true
              "
            >
              <el-date-picker
                v-model="marketingAddCommandModel.activityInfo.getAwardTime"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="getAwardTimes"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
              >
              </el-date-picker>
            </div>
          </el-form-item>

          <el-form-item label="跑马灯：">
            <el-radio-group
              v-model="marketingAddCommandModel.activityInfo.marqueeOpen"
            >
              <el-radio :label="true">开启</el-radio>
              <el-radio :label="false">关闭</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="活动类型：">
            <div style="width:30%;" class="row-around">
              <div
                class="row-center statusBox hands"
                :class="[
                  award.dictValue ==
                  marketingAddCommandModel.activityInfo.specificActivityType
                    ? 'active-type'
                    : ''
                ]"
                v-for="award in awardList"
                :key="award.dictValue"
                @click="changeAward(award)"
              >
                {{ award.dictLabel }}
              </div>
            </div>
          </el-form-item>
          <el-form-item label="选择学院：">
            <el-select
              v-model="marketingAddCommandModel.activityInfo.collegeId"
              placeholder="请选择学院"
            >
              <el-option
                v-for="item in collegesList"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <!-- 抽奖活动 -->
        <el-form
          ref="drawRef"
          label-width="150px"
          size="small"
          :rules="drawRules"
          :model="lotteryActivityConfig"
        >
          <el-form-item label="活动规则" prop="ruleDescribe">
            <div style="width:100%">
              <quill-editor
                ref="text"
                style="height:110px"
                v-model="lotteryActivityConfig.ruleDescribe"
                class="myQuillEditor"
                :options="editorOption"
                @change="onEditorChangeLottery($event)"
                @blur="onEditorBlurLottery($event)"
              ></quill-editor>
            </div>

            <div class="limit">
              <span>{{ nowLengthLottery }}</span> / {{ maxLenLottery }}
            </div>
          </el-form-item>
          <el-form-item label="初始抽奖次数" prop="initialDraws">
            <el-input-number
              :precision="0"
              v-model="lotteryActivityConfig.initialDraws"
              controls-position="right"
              @change="handleChange"
              :min="1"
              :max="awardLength"
            ></el-input-number>
          </el-form-item>

          <el-form-item
            label="免费抽奖"
            prop="freeDraws"
            :rules="{
              required: freeRequired,
              validator: (rules, value, callback) => {
                validFree(rules, value, callback)
              }
            }"
          >
            <div
              v-for="(item, index) of copyFreeDraws"
              :key="index"
              class="free-width"
              style="margin-top: 10px"
            >
              <el-select
                v-model="copyFreeDraws[index].freeDrawUserType"
                placeholder="请选择活动区域"
              >
                <el-option
                  v-for="item in freeDraws"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                >
                </el-option>
              </el-select>
              <el-input-number
                v-if="copyFreeDraws[index].freeDrawUserType"
                :precision="0"
                class="form-option"
                v-model="copyFreeDraws[index].drawsNumber"
                controls-position="right"
                @change="handleChange"
                :min="1"
                :max="awardLength"
              ></el-input-number>
              <span
                style="margin-left: 10px"
                v-if="copyFreeDraws[index].freeDrawUserType"
                >次/天</span
              >
              <el-button
                type="danger"
                icon="el-icon-delete"
                @click="deleteFree(index)"
                style="
                  height: 32px;
                  width: 80px;
                "
                class="form-option"
                >删除</el-button
              >
              <el-button
                class="form-button"
                type="primary"
                icon="el-icon-plus"
                @click="addFree"
                style="
                  height:32px;
                  width: 80px;
                "
                v-if="index == copyFreeDraws.length - 1"
                >新增</el-button
              >
            </div>
          </el-form-item>
          <el-form-item prop="payDraws" label="付费抽奖">
            <div>
              <span>付费抽奖</span>
              <el-radio-group
                v-model="lotteryActivityConfig.payDraws.open"
                style="margin-left: 20px"
              >
                <el-radio :label="true">开启</el-radio>
                <el-radio :label="false">关闭</el-radio>
              </el-radio-group>
            </div>
            <div v-if="lotteryActivityConfig.payDraws.open == true">
              <span>抽奖消耗</span>
              <el-select
                style="margin-left: 20px"
                v-model="lotteryActivityConfig.payDraws.payType"
                placeholder="请选择抽奖类型"
              >
                <el-option
                  v-for="item in payList"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                >
                </el-option>
              </el-select>
              <el-input-number
                :precision="0"
                style="margin-left: 10px"
                v-model="lotteryActivityConfig.payDraws.num"
                controls-position="right"
                @change="handleChange"
                :min="1"
                :max="awardLength"
              ></el-input-number>
            </div>
            <div
              style="margin-top: 10px"
              v-if="lotteryActivityConfig.payDraws.open == true"
            >
              <span>抽奖上限</span>
              <el-input-number
                :precision="0"
                style="margin-left: 20px"
                v-model="lotteryActivityConfig.payDraws.maxNum"
                controls-position="right"
                @change="handleChange"
                :min="1"
                :max="awardLength"
              ></el-input-number>
              <span style="padding: 20px; font-size: 18px">次/天</span>
            </div>
          </el-form-item>
          <el-form-item prop="awards" label="奖品设置">
            <div
              v-for="(item, index) of lotteryActivityConfig.awards"
              :key="index"
            >
              <div style="font-size: 20px; font-weight: bold">
                奖项{{ index + 1 }}
              </div>
              <div style="margin-top: 10px">
                <span style="margin-right: 20px">奖品类型</span>
                <el-radio-group
                  @change="
                    (val) => {
                      getAwardType(val, index)
                    }
                  "
                  v-model="lotteryActivityConfig.awards[index].prize.type"
                >
                  <el-radio
                    :label="item.dictValue"
                    v-for="item in awardType"
                    :key="item.dictValue"
                    >{{ item.dictLabel }}</el-radio
                  >
                </el-radio-group>
              </div>
              <div style="margin-top: 10px">
                <span style="margin-right: 20px">奖品内容</span>
                <el-select
                  size="small"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE'
                  "
                  v-model="
                    lotteryActivityConfig.awards[index].prize.virtualPrizeTypes
                  "
                  @change="
                    (val) => {
                      getAwardInfo(val, index)
                    }
                  "
                  placeholder="请选择活动区域"
                >
                  <el-option
                    v-for="item in awardSets"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                  >
                  </el-option>
                </el-select>
                <el-input
                  size="small"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'PHYSICALS_PRIZE'
                  "
                  v-model="lotteryActivityConfig.awards[index].prize.prizeName"
                  @blur="
                    lotteryActivityConfig.awards[
                      index
                    ].prize.prizeName = $event.target.value.trim()
                  "
                  clearable
                  :maxlength="maxLength"
                  style="width: 200px;"
                >
                </el-input>
                <el-button
                  style="height: 40px; margin-left: 10px"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE' &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'COUPON' &&
                      !lotteryActivityConfig.awards[index].prize.prizeName
                  "
                  type="primary"
                  @click="addCoupons(index, '', 'draw')"
                  >添加优惠券</el-button
                >
                <el-button
                  style="height: 40px; margin-left: 10px"
                  type="primary"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.prizeName &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'COUPON' &&
                      lotteryActivityConfig.awards[index].prize.type ==
                        'VIRTUAL_PRIZE'
                  "
                  >{{
                    lotteryActivityConfig.awards[index].prize.prizeName
                  }}</el-button
                >
                <el-button
                  style="height: 40px; margin-left: 10px"
                  type="primary"
                  @click="addCoupons(index, '', 'draw')"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.prizeName &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'COUPON' &&
                      lotteryActivityConfig.awards[index].prize.type ==
                        'VIRTUAL_PRIZE'
                  "
                  >重新选择</el-button
                >
                <span
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'PHYSICALS_PRIZE'
                  "
                  style="margin-left: 10px"
                  >数量</span
                >
                <span
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE' &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'INTEGRAL'
                  "
                  style="margin-left: 10px"
                  >数量</span
                >
                <el-input-number
                  :precision="0"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'PHYSICALS_PRIZE'
                  "
                  style="margin-left: 10px"
                  v-model="
                    lotteryActivityConfig.awards[index].prize.maxPrizeNum
                  "
                  controls-position="right"
                  @change="handleChange"
                  :min="1"
                  :max="awardLength"
                ></el-input-number>
                <el-input-number
                  :precision="0"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE' &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'COUPON'
                  "
                  style="margin-left: 10px"
                  v-model="
                    lotteryActivityConfig.awards[index].prize.maxPrizeNum
                  "
                  controls-position="right"
                  @change="handleChange"
                  :min="1"
                  :max="awardLength"
                ></el-input-number>
                <el-input-number
                  :precision="0"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE' &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'FLOWER'
                  "
                  style="margin-left: 10px"
                  v-model="
                    lotteryActivityConfig.awards[index].prize.maxPrizeNum
                  "
                  controls-position="right"
                  @change="handleChange"
                  :min="1"
                  :max="awardLength"
                ></el-input-number>
                <el-input-number
                  :precision="0"
                  v-if="
                    lotteryActivityConfig.awards[index].prize.type ==
                      'VIRTUAL_PRIZE' &&
                      lotteryActivityConfig.awards[index].prize
                        .virtualPrizeTypes == 'INTEGRAL'
                  "
                  style="margin-left: 10px"
                  v-model="lotteryActivityConfig.awards[index].prize.num"
                  controls-position="right"
                  @change="handleChange"
                  :min="1"
                  :max="awardLength"
                ></el-input-number>
              </div>
              <div style="margin-top: 10px">
                <span>中奖概率</span>
                <el-input-number
                  :precision="0"
                  style="margin-left: 20px"
                  v-model="
                    lotteryActivityConfig.awards[index].probabilityOfWinning
                  "
                  @change="handleChange"
                  @blur="handleBlur(index)"
                  :min="0"
                  :max="100"
                  label="描述文字"
                ></el-input-number>
                <span>%</span>
                <el-button
                  class="form-button"
                  icon="el-icon-delete"
                  type="danger"
                  @click="deleteAwardSet(index)"
                  style="
                    height: 32px;
                    width: 80px;
                  "
                  >删除</el-button
                >
                <el-button
                  class="form-button"
                  type="primary"
                  icon="el-icon-plus"
                  @click="addAward"
                  style="
                    height: 32px;
                    width: 80px;
                  "
                  v-if="index == lotteryActivityConfig.awards.length - 1"
                  >添加</el-button
                >
              </div>
            </div>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row type="flex" justify="center">
      <el-col :span="12" :offset="12" class="complie-btn">
        <el-button
          type="primary"
          @click="complie"
          v-if="this.$route.query.type == 'complie'"
          >保存</el-button
        >
        <el-button type="primary" @click="onSubmit" v-else>保存</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-col>
    </el-row>
    <addCounpDialog
      :formInline="formInline"
      :total="total"
      :pages="pages"
      @backData="backData"
      @generlData="addCoupons()"
    ></addCounpDialog>
  </div>
</template>

<script>
import '@assets/css/quill.snow.css'
import { quillEditor } from 'vue-quill-editor'
import {
  addActives,
  maxNum,
  searchActive,
  changeActives
} from '@/api/activeList/index.js'
import { clearTagMixins } from '@/mixins/clearTag'
import { sysNormalDisable } from '@utils/dictionariesFunc.js'
import addCounpDialog from '@component/markingActive/common/addCounpDialog'
import uploadSingImg from '@common/uploadSingImg' // 上传单个图片公共组件
import uploadImg from '@common/uploadImg' // 导入

export default {
  mixins: [clearTagMixins],
  data() {
    var validAward = (rule, value, callback) => {
      if (
        this.marketingAddCommandModel.activityInfo.receiveAwardConfig.open ==
        true
      ) {
        if (
          !this.marketingAddCommandModel.activityInfo.getAwardTime ||
          this.marketingAddCommandModel.activityInfo.getAwardTime.length == 0
        ) {
          callback(new Error('请输入领奖时间'))
        } else {
          callback()
        }
      } else {
        callback()
      }
    }

    var validFire = (rule, value, callback) => {
      if (
        this.marketingAddCommandModel.activityInfo.warmUpConfig.open == true
      ) {
        if (
          !this.marketingAddCommandModel.activityInfo.hotFireTime ||
          this.marketingAddCommandModel.activityInfo.hotFireTime.length == 0
        ) {
          callback(new Error('请选择预热时间'))
        } else if (
          !this.marketingAddCommandModel.activityInfo.warmUpConfig.cover
        ) {
          callback(new Error('请上传图片'))
          return
        } else {
          callback()
        }
      } else {
        callback()
      }
    }

    var validRule = (rule, value, callback) => {
      if (this.nowLengthLottery > 500) {
        callback(new Error('文章内容不超过五百字'))
      } else {
        callback()
      }
    }

    var validPay = (rule, value, callback) => {
      if (this.lotteryActivityConfig.payDraws.open == true) {
        if (
          !this.lotteryActivityConfig.payDraws.payType ||
          !this.lotteryActivityConfig.payDraws.maxNum ||
          !this.lotteryActivityConfig.payDraws.num
        ) {
          callback(new Error('必填项不能为空'))
        } else {
          callback()
        }
      } else {
        callback()
      }
    }
    var validAwards = (rule, value, callback) => {
      let award = this.lotteryActivityConfig.awards.map((item) => {
        if (item.prize.type == 'PHYSICALS_PRIZE') {
          if (!item.prize.prizeName) {
            return 'noprizeName'
          }
          if (!item.prize.maxPrizeNum) {
            return 'nomaxPrizeNum'
          }
        }
        if (item.prize.type == 'VIRTUAL_PRIZE') {
          if (!item.prize.virtualPrizeTypes) {
            return 'novirtualPrizeTypes'
          } else {
            if (item.prize.virtualPrizeTypes == 'INTEGRAL') {
              if (!item.prize.num) {
                return 'nonum'
              } else {
                return true
              }
            }
            if (item.prize.virtualPrizeTypes == 'COUPON') {
              if (!item.prize.couponId) {
                // callback(new Error('请选择优惠券'))
                // return false
                return 'nocouponId'
              } else {
                return true
              }
            }
          }
        }
        // callback()
      })
      if (award.includes('noprizeName')) {
        callback(new Error('请填写实物奖品名称'))
      } else if (award.includes('nomaxPrizeNum')) {
        callback(new Error('请填写数量'))
      } else if (award.includes('novirtualPrizeTypes')) {
        callback(new Error('请选择抽奖类型'))
      } else if (award.includes('nonum')) {
        callback(new Error('请选择积分数量'))
      } else if (award.includes('nocouponId')) {
        callback(new Error('请选择优惠券'))
      } else {
        callback()
      }
    }
    return {
      awardLength: 0,
      items: [
        'source',
        'preview',
        'wordpaste',
        '|',
        'justifyleft',
        'justifycenter',
        'justifyright',
        'justifyfull',
        'insertorderedlist',
        'insertunorderedlist',
        'indent',
        '|',
        'formatblock',
        'fontsize',
        'forecolor',
        'hilitecolor',
        'bold',
        'italic',
        'underline',
        'strikethrough'
      ],
      addActivesRules: {
        getAwardTime: [
          {
            validator: validAward,
            trigger: 'blur'
          }
        ],
        hotFireTime: [
          {
            validator: validFire,
            trigger: 'blur'
          }
        ],
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { max: 20, message: '长度不能大于20个字符', trigger: 'blur' }
        ],
        activeTime: [
          { required: true, message: '请选择活动起始时间', trigger: 'change' }
        ],
        poster: [
          {
            required: true,
            message: '请添加海报',
            trigger: 'change'
          }
        ]
      },
      editorOption: {
        modules: {
          toolbar: {
            container: [
              ['bold', 'italic', 'underline', 'strike'],
              [{ header: 1 }, { header: 2 }],
              [{ list: 'ordered' }, { list: 'bullet' }],
              [{ color: [] }, { background: [] }],
              [{ align: [] }]
            ]
          },
          clipboard: {
            matchers: [[Node.ELEMENT_NODE, this.handleCustomMatcher]]
          }
        },
        placeholder: '请输入正文'
      },
      gengelReselect: false,
      ladder: [],
      awardSets: [],
      awardType: [],
      payList: [],
      // 抽奖校验
      drawRules: {
        awards: [
          {
            validator: validAwards,
            trigger: 'blur'
          }
        ],
        payDraws: [
          {
            validator: validPay,
            trigger: 'blur'
          }
        ],
        ruleDescribe: [
          {
            required: true,
            message: '请填写活动规则',
            trigger: ['change', 'blur']
          },
          {
            validator: validRule,
            trigger: ['change', 'blur']
          }
        ],
        initialDraws: [
          {
            required: true,
            message: '初始抽奖次数不能为空',
            trigger: 'change'
          }
        ]
      },
      copyFreeDraws: [
        {
          drawsNumber: '',
          freeDrawUserType: ''
        }
      ],
      //  抽奖活动
      lotteryActivityConfig: {
        awards: [
          {
            prize: {
              couponId: '',
              maxPrizeNum: '',
              num: '',
              prizeName: '',
              type: 'VIRTUAL_PRIZE',
              virtualPrizeTypes: 'INTEGRAL'
            },
            probabilityOfWinning: ''
          }
        ],
        freeDraws: [],
        initialDraws: 0,
        payDraws: {
          maxNum: 0,
          num: 0,
          payType: 'INTEGRAL',
          open: false
        },
        ruleDescribe: ''
      },
      ladelCounp: '',
      maxLength: 0,

      marketingAddCommandModel: {
        activityInfo: {
          getAwardTime: [],
          hotFireTime: [],
          activeTime: [],
          collegeId: '',
          name: '',
          endTime: '',
          startTime: '',
          marqueeOpen: false,
          // 活动领奖配置
          receiveAwardConfig: {
            endTime: '',
            open: false,
            startTime: ''
          },
          type: 'LOTTERY_ACTIVITY',
          specificActivityType: 'GONGGE_LOTTERY',
          // 活动预热
          warmUpConfig: {
            cover: '',
            endTime: '',
            open: false,
            startTime: ''
          }
        }
      },
      textContent: '',
      nowLength: 0,
      nowLengthLottery: 0,
      maxLen: 500,
      maxLenLottery: 500,
      overText: false, //富文本字数是否超过500
      overTextLottery: false,
      gengelCounp: '',
      ladderList: [],
      checkedValue: '',
      checkedCounp: '',
      reselect: false,
      // 优惠券弹窗
      total: 0,
      formInline: {
        show: false,
        // counpList: [],
        index: '',
        type: '',
        ind: ''
      },
      pages: {
        page: 1,
        size: 10
      },
      BeInvitedList: [],
      beInvitedAward: [],
      // 添加文件参数
      activeTime: [],
      getAwardTime: [],
      hotFireTime: [],

      // 免费抽奖
      freeDraws: [],
      awardSet: [
        {
          content: ''
        }
      ],
      radio: '',
      freeDraw: [
        {
          drawsNumber: '',
          freeDrawUserType: ''
        }
      ],
      textarea: '',
      img: '',

      userMove: [
        {
          content: ''
        }
      ],
      // 阶段性奖励
      awardInvite: 'open',
      num: 0,
      statusList: [],
      clickedStatus: 'INVITE_ACTIVITY',
      awardList: [],
      // clickAward: '',
      collegesList: [],
      value1: [],

      userMoves: [],
      behavesList: [],
      inviteMode: [],
      postId: ''
    }
  },
  created() {
    this.awardMaxNum()
    this.postId = this.$route.query.id
    if (
      this.$route.query.type == 'complie' ||
      this.$route.query.type == 'copy'
    ) {
      this.searchActive()
    }
  },
  activated() {
    this.toTableScrollHeight()
  },
  mounted() {
    this.inviteLoad()
    this.getColleges()
    this.getActivesStates()
    this.getBeInvited()
    this.userBehavor()
    this.inviteModel()
    this.getNumMax()
    this.getFreeDraw()
  },
  components: {
    uploadSingImg,
    addCounpDialog,
    quillEditor
  },
  methods: {
    validFree(rules, value, callback) {
      // let freeDraw = this.lotteryActivityConfig.freeDraws
      // 免费抽奖为选填 当只有一条 而且没有选择选项时候不进行校验
      if (
        this.copyFreeDraws.length == 1 &&
        !this.copyFreeDraws[0].freeDrawUserType
      ) {
        callback()
      } else {
        let free = this.copyFreeDraws.map((item) => {
          if (!item.freeDrawUserType || !item.drawsNumber) {
            callback(new Error('必填项不能为空'))
          }
          return item.freeDrawUserType
        })
        if (this.isRepeat(free)) {
          callback(new Error('有相同类型用户'))
        } else {
          callback()
        }
      }
    },
    onSubmit() {
      let addActivesss
      let lottery
      this.$refs['addActives'].validate((valid) => {
        addActivesss = valid
        if (!valid) {
          this.$message.warning('请检查必填项')
        }
      })
      this.$refs['drawRef'].validate((valid) => {
        lottery = valid
        if (!valid) {
          this.$message.warning('请检查必填项')
        }
      })
      if (addActivesss && lottery) {
        if (
          this.copyFreeDraws.length == 1 &&
          !this.copyFreeDraws[0].freeDrawUserType
        ) {
          this.lotteryActivityConfig.freeDraws = []
        } else {
          this.lotteryActivityConfig.freeDraws = this.copyFreeDraws
        }
        this.marketingAddCommandModel.lotteryActivityConfig = this.lotteryActivityConfig
        let params = { ...this.marketingAddCommandModel }
        addActives(
          params,
          (res) => {
            this.clearTag()
          },
          (err) => {
            this.$message({
              message: err.message,
              type: 'warning'
            })
          }
        )
      }
    },
    handleCustomMatcher(node, Delta) {
      if (this.clearStyle) {
        let ops = []
        Delta.ops.forEach((op) => {
          if (op.insert && typeof op.insert === 'string') {
            ops.push({
              insert: op.insert
            })
          }
        })
        Delta.ops = ops
        return Delta
      } else {
        return Delta
      }
    },
    onEditorBlur(event) {},
    onEditorBlurLottery(event) {},
    onEditorChangeLottery(event) {
      let value = event.quill.getText()
      this.textContent = value.slice(0, -1)
      if (this.lotteryActivityConfig.ruleDescribe === '') {
        this.nowLengthLottery = 0
      } else {
        this.nowLengthLottery = value.length - 1
      }
      this.overTextLottery =
        this.nowLengthLottery > this.maxLenLottery ? true : false
      if (this.overTextLottery) {
        this.$message.warning(`文章内容不超过${this.maxLenLottery}字`)
      }
    },
    onEditorChange(event) {
      let value = event.quill.getText()
      this.textContent = value.slice(0, -1)
      if (this.inviteActivityConfig.ruleDescribe === '') {
        this.nowLength = 0
      } else {
        this.nowLength = value.length - 1
      }
      this.overText = this.nowLength > this.maxLen ? true : false
      if (this.overText) {
        this.$message.warning(`文章内容不超过${this.maxLen}字`)
      }
    },
    signOut() {
      this.$router.go(-1)
    },
    isRepeat(arr) {
      let obj = {}
      for (let i in arr) {
        if (obj[arr[i]]) return true
        obj[arr[i]] = true
      }
      return false
    },
    awardMaxNum() {
      let obj = {
        configKey: 'marketing_activity_prize_number_limit'
      }
      maxNum(
        obj,
        (res) => {
          this.awardLength = res
        },
        (err) => {}
      )
    },
    getInvitedContent(content) {
      this.inviteActivityConfig.ruleDescribe = content
      this.$refs['invitedRef'].clearValidate('ruleDescribe')
    },
    getContent(content) {
      this.lotteryActivityConfig.ruleDescribe = content
      this.$refs['drawRef'].clearValidate('ruleDescribe')
    },
    dueDateToActiveTime(startTime, endTime) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'activeTime', [
        startTime,
        endTime
      ])
    },
    dueDateToFireTime(startTime, endTime) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'hotFireTime', [
        startTime,
        endTime
      ])
    },
    dueDateToAwardTime(startTime, endTime) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'getAwardTime', [
        startTime,
        endTime
      ])
    },
    searchActive() {
      let _this = this
      let obj = {}
      searchActive(
        this.postId,
        obj,
        (res) => {
          _this.marketingAddCommandModel.activityInfo = res.activityInfo
          this.clickedStatus = res.activityInfo.type
          _this.lotteryActivityConfig = res.lotteryActivityConfig
          //  当免费抽奖的时候有值的话 才把这个值赋值给免费抽奖遍历的数组 如果没值的话 就直接用写死的为空的值
          if (res.lotteryActivityConfig.freeDraws.length > 0) {
            _this.copyFreeDraws = res.lotteryActivityConfig.freeDraws
          }
          this.dueDateToActiveTime(
            res.activityInfo.startTime,
            res.activityInfo.endTime
          )
          if (
            res.activityInfo.warmUpConfig.endTime &&
            res.activityInfo.warmUpConfig.startTime
          ) {
            this.dueDateToFireTime(
              res.activityInfo.warmUpConfig.startTime,
              res.activityInfo.warmUpConfig.endTime
            )
          }
          if (
            res.activityInfo.receiveAwardConfig.startTime &&
            res.activityInfo.receiveAwardConfig.endTime
          ) {
            this.dueDateToAwardTime(
              res.activityInfo.receiveAwardConfig.startTime,
              res.activityInfo.receiveAwardConfig.endTime
            )
          }
        },
        (err) => {}
      )
    },
    checkLabelState(val, ind, index) {
      let _this = this
      if (val == 'PHYSICALS_PRIZE') {
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].type =
          'PHYSICALS_PRIZE'
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].prizeName =
          ''
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].couponId =
          ''
      } else {
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].type =
          'VIRTUAL_PRIZE'
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].prizeName =
          ''
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].couponId =
          ''
      }
    },
    getAwardType(val, index) {
      if (val == 'PHYSICALS_PRIZE') {
        this.lotteryActivityConfig.awards[index].prize.type = 'PHYSICALS_PRIZE'
        this.lotteryActivityConfig.awards[index].prize.prizeName = ''
      } else {
        this.lotteryActivityConfig.awards[index].prize.type = 'VIRTUAL_PRIZE'
      }
    },
    getAwardInfo(val, index) {
      if (val == 'INTEGRAL') {
        this.lotteryActivityConfig.awards[index].prize.prizeName = '积分'
        this.lotteryActivityConfig.awards[index].prize.maxPrizeNum = ''
        this.lotteryActivityConfig.awards[index].prize.couponId = ''
      }
      if (val == 'COUPON') {
        this.lotteryActivityConfig.awards[index].prize.prizeName = ''
        this.lotteryActivityConfig.awards[index].prize.num = ''
      }
      if (val == 'PHYSICALS_PRIZE') {
        this.lotteryActivityConfig.awards[index].prize.num = ''
        this.lotteryActivityConfig.awards[index].prize.couponId = ''
      }
      this.lotteryActivityConfig.awards[index].prize.virtualPrizeTypes = val
    },
    // 免费抽奖类型
    async getFreeDraw() {
      let specificActivityType = await sysNormalDisable(
        'specific_marketing_activity_type',
        'specific_marketing_activity_type'
      )
      this.awardList = specificActivityType.filter(
        (item) => item.dictValue !== 'INVITE_ACTIVITY'
      )
      let data = await sysNormalDisable(
        'free_draw_user_type',
        'free_draw_user_type'
      )
      let obj = [
        {
          dictValue: '',
          dictLabel: '请选择'
        }
      ]
      this.freeDraws = obj.concat(data)
      let payData = await sysNormalDisable(
        'marketing_lottery_pay_type',
        'marketing_lottery_pay_type'
      )
      let payObj = [
        {
          dictValue: '',
          dictLabel: '选择奖品'
        }
      ]
      this.payList = payObj.concat(payData)
      this.awardType = await sysNormalDisable(
        'marketing_prize_type',
        'marketing_prize_type'
      )
      //奖品设置
      let awardSet = await sysNormalDisable(
        'marketing_virtual_prize_type',
        'marketing_virtual_prize_type'
      )
      let awardSetObj = [
        {
          dictValue: '',
          dictLabel: '选择奖品'
        }
      ]
      this.awardSets = awardSetObj.concat(awardSet)
    },
    checkedUserBehavor(val, index) {
      let behavior = this.inviteActivityConfig.inviteUserAwards.behaviorRewards
      if (val == 'PHYSICALS_PRIZE') {
        behavior[index].prize.type = 'PHYSICALS_PRIZE'
        behavior[index].prize.prizeName = ''
      } else {
        if (val == 'INTEGRAL') {
          behavior[index].prize.prizeName = '积分'
        }
        if (val == 'COUPON') {
          behavior[index].prize.prizeName = ''
        }
        behavior[index].prize.type = 'VIRTUAL_PRIZE'
      }
    },

    stageRewardAction(val, index) {
      if (val == 'PHYSICALS_PRIZE') {
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
          index
        ].prize.type = 'PHYSICALS_PRIZE'
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
          index
        ].prize.prizeName = ''
      } else {
        if (val == 'INTEGRAL') {
          this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
            index
          ].prize.prizeName = '积分'
        }
        if (val == 'COUPON') {
          this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
            index
          ].prize.prizeName = ''
        }
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
          index
        ].prize.type = 'VIRTUAL_PRIZE'
      }
    },
    getNumMax() {
      let obj = {
        configKey: 'marketing_activity_prize_name_limit'
      }
      maxNum(
        obj,
        (res) => {
          this.maxLength = res
        },
        () => {}
      )
    },
    // 普通模式
    deletegeneral(index) {
      if (
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards.length ==
        1
      ) {
        this.$message({
          message: '至少保留一个',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.generalRewardAwards.splice(
        index,
        1
      )
    },
    addgeneral() {
      if (
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards.length ==
        3
      ) {
        this.$message({
          message: '不能添加超过三个',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.generalRewardAwards.push({
        couponId: '',
        num: '',
        prizeName: '',
        type: '',
        virtualPrizeTypes: ''
      })
    },
    // 邀请模式
    async inviteModel() {
      this.inviteMode = await sysNormalDisable(
        'marketing_award_model',
        'marketing_award_model'
      )
    },
    // 用户行为奖励
    async userBehavor() {
      let data = await sysNormalDisable(
        'marketing_user_behavior',
        'marketing_user_behavior'
      )
      let obj = [
        {
          dictValue: '',
          dictLabel: '用户行为'
        }
      ]
      this.userMoves = obj.concat(data)
    },
    // 不能重复选择同一个奖品
    checkedAward(val, index, item) {
      if (val == 'PHYSICALS_PRIZE') {
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].type = 'PHYSICALS_PRIZE'
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].prizeName = ''
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].couponId = ''
      } else {
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].type = 'VIRTUAL_PRIZE'
        if (val == 'INTEGRAL') {
          this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
            index
          ].prizeName = '积分'
          this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
            index
          ].couponId = ''
        }
        if (val == 'COUPON') {
          this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
            index
          ].prizeName = ''
          this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
            index
          ].couponId = ''
        }
      }
    },
    backData(backData, index, ind, type) {
      if (type == 'general') {
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].couponId = backData.id
        this.inviteActivityConfig.inviteUserAwards.generalRewardAwards[
          index
        ].prizeName = backData.couponName
      }
      if (type == 'beInvited') {
        this.inviteActivityConfig.inviteesUserAwards[index].couponId =
          backData.id
        this.inviteActivityConfig.inviteesUserAwards[index].prizeName =
          backData.couponName
      }
      if (type == 'stage') {
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
          index
        ].prize.couponId = backData.id
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards[
          index
        ].prize.prizeName = backData.couponName
      }
      if (type == 'behavior') {
        this.inviteActivityConfig.inviteUserAwards.behaviorRewards[
          index
        ].prize.couponId = backData.id
        this.inviteActivityConfig.inviteUserAwards.behaviorRewards[
          index
        ].prize.prizeName = backData.couponName
      }
      if (type == 'ladder') {
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].couponId =
          backData.id
        this.inviteActivityConfig.inviteUserAwards.stage[index][ind].prizeName =
          backData.couponName
      }
      if (type == 'draw') {
        this.lotteryActivityConfig.awards[index].prize.couponId = backData.id
        this.lotteryActivityConfig.awards[index].prize.prizeName =
          backData.couponName
      }
    },
    // 添加优惠券
    addCoupons(index, ind, type) {
      this.formInline.index = index
      this.formInline.type = type
      this.formInline.ind = ind
      this.formInline.show = true
    },

    deleteBeInvited(index) {
      if (this.inviteActivityConfig.inviteesUserAwards.length == 1) {
        this.$message({
          message: '至少保留一条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteesUserAwards.splice(index, 1)
    },
    addBeInvited() {
      if (this.inviteActivityConfig.inviteesUserAwards.length == '3') {
        this.$message({
          message: '最多可以添加三条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteesUserAwards.push({
        couponId: '',
        // maxPrizeNum: '',
        num: '',
        prizeName: '',
        type: 'VIRTUAL_PRIZE',
        virtualPrizeTypes: ''
      })
    },
    // 邀请活动下拉列表字典
    async inviteLoad() {
      let data = await sysNormalDisable(
        'marketing_invitation_prize_type',
        'marketing_invitation_prize_type'
      )
      let obj = [
        {
          dictLabel: '选择奖品',
          dictValue: ''
        }
      ]
      this.ladder = obj.concat(data)
    },
    //  虚拟奖品选项
    async getBeInvited() {
      let data = await sysNormalDisable(
        'marketing_invitation_prize_type',
        'marketing_invitation_prize_type'
      )
      let obj = [{ dictLabel: '选择奖品', dictValue: '' }]
      this.BeInvitedList = obj.concat(data)
      this.behavesList = obj.concat(data)
      this.ladderList = obj.concat(data)
    },
    getActivePost(url) {
      this.$nextTick(() => {
        this.inviteActivityConfig.poster = url
        this.$refs['invitedRef'].clearValidate('poster')
      })
    },
    getImgUrl(url) {
      this.marketingAddCommandModel.activityInfo.warmUpConfig.cover = url
      this.$refs['addActives'].clearValidate('hotFireTime')
    },
    // 获取活动类型
    async getActivesStates() {
      let data = await sysNormalDisable(
        'marketing_activity_type',
        'marketing_activity_type'
      )
      this.statusList = data
    },
    getHotTime(val) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'hotFireTime', [
        val[0],
        val[1]
      ])
      this.marketingAddCommandModel.activityInfo.warmUpConfig.startTime = val[0]
      this.marketingAddCommandModel.activityInfo.warmUpConfig.endTime = val[1]
    },
    getAwardTimes(val) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'getAwardTime', [
        val[0],
        val[1]
      ])
      this.marketingAddCommandModel.activityInfo.receiveAwardConfig.startTime =
        val[0]
      this.marketingAddCommandModel.activityInfo.receiveAwardConfig.endTime =
        val[1]
    },
    // 获得活动起始时间
    getTime(val) {
      this.$set(this.marketingAddCommandModel.activityInfo, 'activeTime', [
        val[0],
        val[1]
      ])
      this.marketingAddCommandModel.activityInfo.endTime = val[1]
      this.marketingAddCommandModel.activityInfo.startTime = val[0]
    },
    handleChange() {},
    handleBlur(index) {
      if (!this.lotteryActivityConfig.awards[index].probabilityOfWinning) {
        this.lotteryActivityConfig.awards[index].probabilityOfWinning = 0
      }
    },
    deleteAwardSet(index) {
      if (this.lotteryActivityConfig.awards.length == 1) {
        this.$message({
          message: '最少不能少于一条',
          type: 'warning'
        })
        return false
      }
      this.lotteryActivityConfig.awards.splice(index, 1)
    },
    addAward() {
      let activesType = this.marketingAddCommandModel.activityInfo
        .specificActivityType
      let activesLength =
        activesType === 'TURNTABLE_LOTTERY' //转盘
          ? 6
          : activesType === 'GONGGE_LOTTERY' //宫格
          ? 8
          : 9
      if (this.lotteryActivityConfig.awards.length >= activesLength) {
        this.$message({
          message: `最多输入${activesLength}条数据`,
          type: 'warning'
        })
        return false
      }
      this.lotteryActivityConfig.awards.push({
        prize: {
          couponId: '',
          maxPrizeNum: '',
          num: '',
          prizeName: '',
          type: 'VIRTUAL_PRIZE',
          virtualPrizeTypes: 'INTEGRAL'
        },
        probabilityOfWinning: ''
      })
    },
    deleteFree(index) {
      if (this.copyFreeDraws.length == 1) {
        this.$message({
          message: '最少要留一条',
          type: 'warning'
        })
        return false
      }
      this.copyFreeDraws.splice(index, 1)
    },
    addFree() {
      if (this.copyFreeDraws.length == 4) {
        this.$message({
          message: '免费抽奖最多不可以超过四条',
          type: 'warning'
        })
        return false
      }
      this.copyFreeDraws.push({
        drawsNumber: '',
        freeDrawUserType: ''
      })
    },
    deleteStage(index) {
      if (this.inviteActivityConfig.inviteUserAwards.stage.length == 1) {
        this.$message({
          message: '至少一条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stage.splice(index, 1)
    },
    deleteInner(ind, index) {
      if (this.inviteActivityConfig.inviteUserAwards.stage[index].length == 1) {
        this.$message({
          message: '至少保留一条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stage[index].splice(ind, 1)
    },
    addInner(ind, index) {
      if (this.inviteActivityConfig.inviteUserAwards.stage[index].length == 3) {
        this.$message({
          message: '最多可以添加三条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stage[index].push({
        couponId: '',
        maxPrizeNum: '',
        num: '',
        prizeName: '',
        type: '',
        virtualPrizeTypes: ''
      })
    },
    addStage() {
      if (this.inviteActivityConfig.inviteUserAwards.stage.length == 3) {
        this.$message({
          message: '阶梯奖励不可以超过三个',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stage.push([
        {
          couponId: '',
          maxPrizeNum: '',
          num: '',
          prizeName: '',
          type: '',
          virtualPrizeTypes: ''
        }
      ])
    },
    deleteUserMove(index) {
      if (
        this.inviteActivityConfig.inviteUserAwards.behaviorRewards.length == 1
      ) {
        this.$message({
          message: '最少要保留一条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.behaviorRewards.splice(
        index,
        1
      )
    },
    addUserMove() {
      if (
        this.inviteActivityConfig.inviteUserAwards.behaviorRewards.length == 9
      ) {
        this.$message({
          message: '用户行为奖励最多可添加九条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.behaviorRewards.push({
        prize: {
          couponId: '',
          maxPrizeNum: '',
          num: '',
          prizeName: '',
          type: '',
          virtualPrizeTypes: ''
        },
        disabled: true,
        userBehavior: ''
      })
    },
    // 取消按钮
    cancel() {
      this.clearTag()
    },
    deleteStateAward(index) {
      if (
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig
          .stageRewards.length == 1
      ) {
        this.$message({
          message: '至少需要一条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards.splice(
        index,
        1
      )
    },
    pushStateAward() {
      if (
        this.inviteActivityConfig.inviteUserAwards.stageRewardConfig
          .stageRewards.length == 20
      ) {
        this.$message({
          message: '最多三条',
          type: 'warning'
        })
        return false
      }
      this.inviteActivityConfig.inviteUserAwards.stageRewardConfig.stageRewards.push(
        {
          prize: {
            couponId: '',
            maxPrizeNum: '',
            num: '',
            prizeName: '',
            type: '',
            virtualPrizeTypes: ''
          },
          userNumber: ''
        }
      )
    },
    changeAward(award) {
      // this.clickAward = award.dictValue
      this.marketingAddCommandModel.activityInfo.specificActivityType =
        award.dictValue
      this.lotteryActivityConfig.awards = []
      this.lotteryActivityConfig.awards.push({
        prize: {
          couponId: '',
          maxPrizeNum: '',
          num: '',
          prizeName: '',
          type: 'VIRTUAL_PRIZE',
          virtualPrizeTypes: 'INTEGRAL'
        },
        probabilityOfWinning: ''
      })
    },
    // 活动学院列表
    async getColleges() {
      let data = await sysNormalDisable('sys_college', 'sys_college')
      let addAll = [{ dictLabel: '全部', dictValue: '' }]
      this.collegesList = addAll.concat(data)
    },
    complie() {
      let addActivesss
      let lottery
      this.$refs['addActives'].validate((valid) => {
        addActivesss = valid
      })
      this.$refs['drawRef'].validate((valid) => {
        lottery = valid
      })
      if (addActivesss && lottery) {
        if (
          this.copyFreeDraws.length == 1 &&
          !this.copyFreeDraws[0].freeDrawUserType
        ) {
          this.lotteryActivityConfig.freeDraws = []
        } else {
          this.lotteryActivityConfig.freeDraws = this.copyFreeDraws
        }
        this.marketingAddCommandModel.lotteryActivityConfig = this.lotteryActivityConfig
        let params = { ...this.marketingAddCommandModel }
        changeActives(
          this.postId,
          params,
          (res) => {
            this.$message({
              message: '编辑成功',
              type: 'success'
            })
            this.clearTag()
          },
          (err) => {
            this.$message({
              message: err.message,
              type: 'warning'
            })
          }
        )
      }
    }
  },
  computed: {
    freeRequired() {
      // 当添加的免费抽奖条数大于一的时候
      if (this.copyFreeDraws.length > 1) {
        return true
      } else {
        // 当添加的免费抽奖条数等于一的时候
        // 并且那一条中的数量 和 类型任意一条不为空 返回true 进行校验
        if (
          this.copyFreeDraws[0].drawsNumber ||
          this.copyFreeDraws[0].freeDrawUserType
        ) {
          return true
        } else {
          // 当两个都为空的时候 也就是默认值 什么都没填的时候 不用校验
          return false
        }
      }
    }
  }
}
</script>

<style lang="less" rel="stylesheet/less" scoped>
.quill-editor {
  .ql-container {
    height: calc(100vh - 162px);
    .ql-editor {
      height: calc(~'100% - 30px');
    }
  }
}
.complie-btn {
  padding: 40px 0;
}
.red-note {
  position: absolute;
  bottom: -30px;
  padding-left: 10px;
  color: #f00;
}
.limit {
  height: 30px;
  line-height: 30px;
  text-align: right;
  margin: 20px 0 10px;
  padding-right: 10px;
  span {
    color: #f00;
  }
}
.free-width {
  width: 50%;
}
.form-option {
  margin-left: 30px;
}

.hands {
  cursor: pointer;
}
.active-type {
  background: rgba(2, 167, 240, 1) !important;
}
.form-button {
  margin-left: 20px;
}
.row-around {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.row-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
#addActives {
  .statusBox {
    width: auto;
    padding: 10px 10px;
    height: 30px;
    background: inherit;
    background-color: rgba(215, 215, 215, 1);
    border: none;
    box-shadow: 5px;
    color: white;
    border-radius: 5px;
  }
  .invite {
    :deep(.el-radio-group) {
      display: flex;
      flex-direction: column;
      height: 100px;
      justify-content: space-around;
    }
  }
}
</style>
